<script type="text/javascript">
    function isWeiXin(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    }

    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

    function getCookie(name){
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg))
            return unescape(arr[2]);
        else
            return null;
    }

    function gotoAuth(){
        var hrefWithoutHash = location.href.split('#')[0];
        location.replace("http://cas.winnovator.cn/auth/preAuth?appId=1783791821429760&redirect=" + hrefWithoutHash);
    }

    var ssoToken = getCookie("SSO-TOKEN");
    if(!ssoToken){
        gotoAuth();
    }

    var AppStorage = new function() {

        this.setValueInLocalStorage = function(t, a) {
            localStorage.setItem(t, a)
        }
        ,
        this.getValueInLocalStorage = function(t) {
            return localStorage.getItem(t)
        }
        ,
        this.removeValueInLocalStorage = function(t) {
            localStorage.removeItem(t)
        }
    }
</script>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>儿童自控力测试</title>
        <meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport" />
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="0" />

        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="stylesheet" href="./styles/main1.css"/>
        <style>
            .result-expert img{
                width: 100%;
                height: auto;
            }
        </style>
        <script>var _hmt = _hmt || [];</script>
        <script>
            var paperId = "view1";
            window.eventLogger = {

                log: function(category, action, label){
                    category = paperId + "_" + category;
                    action = paperId + "_" + action;
                    label = paperId + "_" + label;

                    try {
                        _hmt.push(["_trackEvent", category, action, label, 0])
                    } catch (e) {}

                    $.get("http://logger.yoparent.cn/log.html?category=" + category + "&action=" + action + "&label=" + label + "&token=" + AppStorage.getValueInLocalStorage("scale-token"));
                }
            }
        </script>
    </head>
    <body>
        <div class="container" id="container"></div>
        <div class="ending full-page hide" >
            <div class="mesg">
                让朋友们也来试试！
                <div class="share icon-redo2"></div>
            </div>
        </div>
        <div class="orientation full-page hide">
            <div class="orientation-wrap">
                <div class="loading icon-spinner"></div>
                <div class="mesg">请使用竖屏浏览，体验绝佳！</div>
            </div>
        </div>
        <div class="full-page result-box hide">
            <div class="result-img" result-img></div>
            <div class="title" result-title></div>
            <div class="result-wrapper" id="result-wrapper" result-wrapper>
                <ul class="desc" id="result-scroller">
                    <li class="" result-desc></li>
                    <li class="result-expert">
                        <img src="http://static.winnovator.cn/scale/0001/expert001.png" />
                        <img src="http://static.winnovator.cn/scale/985747410.jpg" style="display: block; width: 200px; margin-left: auto;    margin-right: auto;" />
                        <a style="height: 50px"></a>
                    </li>
                </ul>
            </div>
            <div class="btn-wrap" result-btn>
               <!--  <div class="btn bg-primary" id='restart'>关注我们</div> -->
               <div class="btn bg-primary" id='share'>分享</div>
            </div>
            <div class="power">
                <div>
                    powered&nbsp;by&nbsp;优儿学堂
                </div>
                <div>
                    ©版权所有&nbsp;&nbsp;侵权必究
                </div>
            </div>
        </div>
        <script type="text/template" id="quiz-data" style="display:none;"></script>
        <script language="text/template" id="poster-tpl" style="display:none;"></script>
        <script type="text/javascript">
            var yoparent_token = "1xzqkxz377o5596qmbjwlkvsl";
            var yoparent_start_time = "1436603587600";
        </script>
        <script type="text/javascript" src="./scripts/main1.js"></script>
        <script type="text/javascript">
            var data_tpl = null;
            WeittQuiz.run(
                    data_tpl,
                    "#container",
                    "#poster-tpl",
                    { next_page_time: 500,
                        bg_img: "",
                        cover_desc: { duration: 900, animate: "zoomIn" },
                        main_cover_img: { duration: 0, animate: "zoomInDown" },
                        main_answers: { duration: 650, animate: "fadeInUp" }
                    }
            );

            $.ajax({type:'get',url:'http://123.59.44.69:7070/yoparent/scale/initData?url=' + encodeURIComponent(location.href.split('#')[0]),success:function(data){
                var configData =eval('(' + data + ')');
                sysconfig(configData);
                wxconfig(configData);
            }});

            function sysconfig(data){
                var _token = AppStorage.getValueInLocalStorage("scale-token");
                if(!_token){
                    AppStorage.setValueInLocalStorage("scale-token", data.token);
                }
                window.yoparent_token = data.token;
                window.yoparent_start_time = parseInt(data.startTime);
            }
        function wxconfig(data){
             wx.config({
                debug: false,
                appId: data.singatureParm.appId,
                timestamp: parseInt(data.singatureParm.timestamp),
                nonceStr: data.singatureParm.nonceStr,
                signature: data.singatureParm.signature,
                jsApiList: ["onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ"]
            });

            wx.ready(function(){
                wx.checkJsApi({
                    jsApiList: ['chooseImage'],
                    success: function(res) {
                    }
                });
                wx.onMenuShareTimeline({
                    title: '儿童自控力测试',
                    link: 'http://scale.yoparent.cn/view1.html',
                    imgUrl: 'http://static.winnovator.cn/scale/0001/0.jpg',
                    success: function () {
                        eventLogger && eventLogger.log("timeline_success", "share", "timeline");
                    },
                    cancel: function () {
                        eventLogger && eventLogger.log("timeline_cancel", "share", "timeline");
                    }
                });

                wx.onMenuShareAppMessage({
                    title: '儿童自控力测试',
                    desc: '自律是孩子幸福成长的第一准则！以下测试可以帮助你了解你孩子的自制力，请家长根据孩子在平时生活中的表现如实完成以下问题。',
                    link: 'http://scale.yoparent.cn/view1.html',
                    imgUrl: 'http://static.winnovator.cn/scale/0001/0.jpg',
                    type: 'link',
                    dataUrl: '',
                    success: function () {
                        eventLogger && eventLogger.log("group_success", "share", "group");
                    },
                    cancel: function () {
                        eventLogger && eventLogger.log("group_cancel", "share", "group");
                    }
                });
            });
        }
        </script>
        <div style="display:none"></div>

        <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

        <script>
            var _hmt = _hmt || [];
            (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?061e31ddbdbd77c0403205c71bf52730";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
            })();
        </script>
    </body>
</html>
